package com.example.universita.esami;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MainActivity extends BaseActivity  {

	String elencoEsami[] = new String[300];
	final int n_suggerimenti = 5;
	
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        Profilo datiProfilo = new Profilo(this);
        
        SharedPreferences settings = getSharedPreferences (datiProfilo.getNameSharedFile(), 0); 
        
        TextView title =  (TextView) findViewById (R.id.nome);
        title.setText (datiProfilo.getNameOnShared(settings) + " " + datiProfilo.getSurnameOnShared(settings)
        		      + " [" + datiProfilo.getStudentIdOnShared(settings) + "]");
        
        if(datiProfilo.getSpecialOnShared(settings).compareTo(getString(R.string.control_special)) == 0)
        	title.append("\n"+getString(R.string.ma_cdl)+" "+ datiProfilo.getCourseOnShared(settings));
        else
            title.append("\n"+getString(R.string.ma_sp)+" "+getString(R.string.ma_sp)+ datiProfilo.getSpecialOnShared(settings));
        
        generaSuggerimento(1+(int)(Math.random()*n_suggerimenti));
    }
	
	@Override
	public void onResume() {
        generaSuggerimento(1+(int)(Math.random()*n_suggerimenti));
        super.onResume();
    }
	
    public void CaricavotiActivity(View v) { 

    	Intent intent = new Intent(this, Inserimento_voti.class);
    	startActivity(intent); 
    }
    
    public void VisualDocentiActivity(View v) { 

    	Intent intent = new Intent(this, VisualDocenti.class);
    	startActivity(intent); 
    }
    
    public void DocentiActivity(View v) { 

    	Intent intent = new Intent(this, Dialog_docenti.class);
    	startActivity(intent); 
    }
    
    
    public void StatisticActivity(View v) { 

    	Intent intent = new Intent(this, StatisticActivity.class);
    	startActivity(intent); 
    }

    public void DetailsActivity(View v) { 

    	Intent intent = new Intent(this, Details.class);
    	startActivity(intent); 
    	
    }
    
    
    public void CarrieraActivity(View v){
    	
    	Intent intent = new Intent(this, Carriera.class);
    	startActivity(intent); 
    }
    
    public void EditEsamiActivity(View v) { 

    	Intent intent = new Intent(this, VisualEsami.class);
    	startActivity(intent); 
    }
    
    public void NoteActivity(View v){
    	
    	Intent intent = new Intent(this, Note.class);
    	startActivity(intent); 
    	
    }
    
    public void generaSuggerimento(int id){
    	TextView s = (TextView) findViewById(R.id.textView1);
    	s.setGravity(Gravity.CENTER);
    	switch(id){
    	case 1: s.setText(getString(R.string.ma_sugg1)); break;
    	case 2: s.setText(getString(R.string.ma_sugg2)); break;
    	case 3: s.setText(getString(R.string.ma_sugg3)); break;
    	case 4: s.setText(getString(R.string.ma_sugg4)); break;
    	case 5: s.setText(getString(R.string.ma_sugg5)); break;
    	}
    }
}